package middleware

import (
	"github.com/gin-gonic/gin"
	"smart-sensor-cloud/internal/model"
	"smart-sensor-cloud/pkg/fsm"
)

var stateMachine *fsm.StateMachine

func InitDeviceFSM() {
	stateMachine = model.NewDeviceFSM()
}

func DeviceFSMMiddleware() gin.HandlerFunc {
	return func(ctx *gin.Context) {
		ctx.Set("fsm", stateMachine)
		ctx.Next()
	}
}
